package com.itheima.mapper;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.itheima.dto.LogisticsCompanyDTO;
import com.itheima.dto.LogisticsPriceDTO;
import com.itheima.pojo.LogisticsCompany;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
@Mapper
public interface LogisticsCompanyMapper extends BaseMapper<LogisticsCompany> {

    @Select("SELECT lc.* FROM tb_logistics_company lc ${ew.customSqlSegment}")
    Page<LogisticsCompanyDTO> selectCompanyPage(Page<LogisticsCompanyDTO> page,
                                                @Param(Constants.WRAPPER) Wrapper<LogisticsCompany> wrapper);

    @Select("SELECT lp.* FROM tb_logistics_price lp " +
            "WHERE lp.logistics_company_id = #{companyId} AND lp.is_del = 1")
    List<LogisticsPriceDTO> selectPricesByCompanyId(Integer companyId);
}